class Solution {
    public boolean check(int[] nums, int t, int mid) {
        int tmp = 0;
        for (int num : nums) {
            tmp += num / mid + ((num % mid)>0?1:0);
        }
        return tmp <= t;
    }

    public int smallestDivisor(int[] nums, int t) {
        int l = 0, r = (int) 1e6 + 100;
        int mid;
        while (l + 1 < r) {
            mid = l + (r - l) / 2;
            if (check(nums, t, mid))
                r = mid;
            else
                l = mid;
        }
        return r;
    }
}